# akshare_finance/reporter.py
from typing import Optional
import pandas as pd

class ConsoleReporter:
    """简化的控制台报告器"""
    
    def __init__(self, quiet: bool = False, silent: bool = False) -> None:
        self.quiet = quiet
        self.silent = silent

    def print_sector_header(self, sector_name: str) -> None:
        """打印板块头部信息"""
        if self.silent:
            return
        print(f"正在分析: {sector_name}")

    def print_company_report(
        self,
        company_name: str,
        symbol: str,
        analysis_df: Optional[pd.DataFrame],
        main_business_df: Optional[pd.DataFrame],
        dupont_basic_df: Optional[pd.DataFrame] = None,
        dupont_advanced_df: Optional[pd.DataFrame] = None,
    ) -> None:
        """打印公司报告（极简版）"""
        if self.silent:
            return
            
        # 简单的状态指示
        has_data = not (analysis_df is None or analysis_df.empty)
        status = "✅" if has_data else "❌"
        
        if not self.quiet:
            print(f"  {status} {company_name} ({symbol})")

    def print_sector_statistics(self, sector_name: str, stats_df: Optional[pd.DataFrame]) -> None:
        """打印板块统计（可选）"""
        if self.silent or self.quiet:
            return
            
        if stats_df is None or stats_df.empty:
            return
            
        print(f"\n📈 {sector_name} 板块统计:")
        print(stats_df.round(2).to_string(index=False))
        print("-" * 50)